<template>
    <div class="loginBox">

      <Form ref="formInline" :model="formInline" :rules="ruleInline"  :label-width="80" class="centercon">
          <H2>2019Evan学习体验平台</H2>
          <FormItem prop="user" label="用户名">
              <Input type="text" v-model="formInline.user" placeholder="Username">
                  <Icon type="ios-person-outline" slot="prepend"></Icon>
              </Input>
          </FormItem>
          <FormItem prop="password" label="密码">
              <Input type="password" v-model="formInline.password" placeholder="Password">
                  <Icon type="ios-lock-outline" slot="prepend"></Icon>
              </Input>
          </FormItem>
          <div class="handler row">
              <Button type="primary" @click="handleSubmit('formInline')" size="large" class="col-sm-6">登陆</Button>
          </div>
      </Form>
    </div>
 

</template>
<script>
    export default {
        data () {
            return {
                formInline: {
                    user: '',
                    password: ''
                },
                ruleInline: {
                    user: [
                        { required: true, message: '请输入用户名', trigger: 'blur' }
                    ],
                    password: [
                        { required: true, message: '请输入密码', trigger: 'blur' },
                        { type: 'string', min: 6, message: '密码长度不能少于6位', trigger: 'blur' }
                    ]
                }
            }
        },
        methods: {
            handleSubmit(name) {
                this.$refs[name].validate((valid) => {
                    if (valid) {
                       this.$router.push({
                         name:"home",
                         query:{loginFlag:true}
                       })
                       this.$Message.success("登陆成功！")
                    } else {
                        this.$Message.error('登陆失败');
                    }
                })
            }
        }
    }
</script>
<style lang="less" scoped>
.loginBox{
  display: flex;
  position: absolute;
  top:0;
  left:0;
  bottom:0;
  right:0;
  flex-direction: column;
  background: #234;
  justify-content: space-around;
  align-items: center;
  .centercon{
    padding:20px;
    min-width:35vw;
    min-height:35vh;
    background: #fff;
    
    H2 {
      text-align: center;
      font-size:32px;
      margin-bottom: 30px;
    }
    .handler{
      text-align: center;
      margin-left: 30%;
    }
    
  }
}
</style>

